package com.blb.bookms.service.impl;

import com.blb.bookms.dao.BookDAO;
import com.blb.bookms.entity.Book;
import com.blb.bookms.service.BookService;
import com.blb.bookms.util.MyLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDAO bookDAO;

    @MyLog("findAll")
    @Override
    public List<Book> findAll() {
        return bookDAO.selectAll();
    }

    @MyLog("findById")
    @Override
    public Book findById(Long id) {
        return bookDAO.selectById(id);
    }

    @MyLog("save")
    @Override
    public void save(Book book) {
        bookDAO.insert(book);
    }

    @Override
    public void update(Book book) {
        bookDAO.update(book);
    }

    @Override
    public void removeById(Long id) {
        bookDAO.delete(id);
    }
}
